/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package services;

import dao.CartJpaController;
import dao.CategoryJpaController;
import dao.ProductJpaController;
import dao.UserJpaController;
import java.util.List;
import javax.persistence.Persistence;
import pojo.Cart;
import pojo.Category;
import pojo.Product;

/**
 *
 * @author Dell
 */
public class ServiceAdminProducts {
    
  static ProductJpaController controller;
  static CategoryJpaController catcontroller;
  
  
  public ServiceAdminProducts()
  {
      controller = new ProductJpaController(Persistence.createEntityManagerFactory("ServletProjectPU"));
      catcontroller = new CategoryJpaController(Persistence.createEntityManagerFactory("ServletProjectPU"));
  }
  
    
     public List<Product> getAllProducts(){
        
        List<Product> products = controller.findProductEntities();
    
        /*for (Product p : products) {
           // cart.
            System.out.println(p.getName());
         
        }*/
         return products;
          
    }
     
      public List<Category> getAllCategories(){
        
        List<Category> caat = catcontroller.findCategoryEntities();
    
        /*for (Product p : products) {
           // cart.
            System.out.println(p.getName());
         
        }*/
         return caat;
          
    }
  
}
